<?php

class UserFunc extends Module
{
    function __construct()
    {
    }
    
    function deal()
    {
        $ret = array('ret'=>true, 'info'=>'成功.');
        $params = isset( $_POST['params'] ) ? trim( $_POST['params'] ) : '';
        $pin = isset( $_POST['pin'] ) ? trim( $_POST['pin'] ) : '';
        $code = isset( $_POST['code'] ) ? trim( $_POST['code'] ) : '';
        $func = create_function( $params, $code );
        if( $func == false )
        {
            echo json_encode( array( 'ret'=>false, 'info'=>'false function.' ) );
            return;
        }
        
        try {
            $ret['data'] = $func( $pin );
        } catch( Exception $e ) {
            echo json_encode( array( 'ret'=>false, 'info'=>'exec failed.' ) );
            return;
        }
        echo json_encode( $ret );
    }
    
    function display()
    {
        parent::smartyOut('userfunc');
    }
}
